package org.vartist.atld.menu.adapter;

import java.util.ArrayList;

import org.vartist.atld.R;
import org.vartist.atld.menu.activity.main.MainActivity;
import org.vartist.atld.menu.vo.MenuVO;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MenuListAdapter extends ArrayAdapter<MenuVO> {
	
	private Activity mActivity = null;
	private ArrayList<MenuVO> mMenuList = null;
	private int mMenuListItemView;
	
	private LayoutInflater mInflater = null;
	private View mCustomCell = null;
	private ImageView mImgMenuIcon = null;
	private TextView mTxtMenuName = null;
	private ImageView mImgMenuArrowImage = null;
	
	public MenuListAdapter(Activity activity, int menuListItemView, ArrayList<MenuVO> menuList) {
		super(activity, menuListItemView, menuList);
		
		mActivity = activity;
		mMenuList = menuList;
		mMenuListItemView = menuListItemView;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		mInflater = mActivity.getLayoutInflater();
		mCustomCell = mInflater.inflate(mMenuListItemView, null);
		
		mImgMenuIcon = (ImageView) mCustomCell.findViewById(R.id.menuIconImageView);
		mTxtMenuName = (TextView) mCustomCell.findViewById(R.id.menuNameTextView);
		mImgMenuArrowImage = (ImageView) mCustomCell.findViewById(R.id.menuIconArrowImageView);
		
		MenuVO menuVO = mMenuList.get(position);
		mImgMenuIcon.setBackgroundResource(menuVO.getMenuIcon());
		mTxtMenuName.setText(menuVO.getMenuName());
		mImgMenuArrowImage.setBackgroundResource(menuVO.getMenuMoreIcon());

		return mCustomCell;
	}
}
